package java6;

import java.util.Scanner;

public class Code074 {
	public static void main(String[] args) {
		System.out.println("***********************************");
		System.out.println("请选择购买的商品编号:");
		System.out.println("1.T 恤\t2.网球鞋\t3.网球拍");
		System.out.println("***********************************\n\n");
		Scanner input = new Scanner(System.in);
		double sum1= 0;
		double sum2= 0;
		double sum3= 0;
		double sum;
		String a = "y";
		while(a.equals("y")){
				System.out.print("请输入商品编号        ");
			while(!input.hasNextInt()){
				System.out.println("输入编号不存在！请重新输入:     ");
				input.next();
			}
			int num1 = input.nextInt();
			while(num1>3){
				System.out.println("输入编号不存在！请重新输入:     ");
				int num1s=input.nextInt();
				num1=num1s;
			}
			System.out.print("请输入购买数量        ");
			while(!input.hasNextInt()){
				System.out.println("输入数量不存在！请重新输入:     ");
				input.next();
			}
			int num2 = input.nextInt();
			switch(num1){
			case 1:
				sum1= sum1+245.0*num2;
				System.out.println("T 恤  ￥245.0\t数量 "+num2+"\t合计￥"+sum1);
				System.out.println("是否继续(y/n)");
				String b = input.next();
				a=(String)b;
				break;
			case 2:
				sum2= sum2+570.0*num2;
				System.out.println("网球鞋  ￥570.0\t数量 "+num2+"\t合计￥"+sum2);
				System.out.println("是否继续(y/n)");
				String c = input.next();
				a=(String)c;
				break;
			case 3:
				sum3= sum3+245.0*num2;
				System.out.println("网球拍  ￥3000.0\t数量 "+num2+"\t合计￥"+sum3);
				System.out.println("是否继续(y/n)");
				String d = input.next();
				a=(String)d;
				break;
			default:
				System.out.println("输入编号不存在！");
				break;
			}
		}
			System.out.println("折扣:0.8");	
			sum = sum1+sum2+sum3;
			System.out.println("应付金额:"+sum);
			System.out.print("实付金额:      ");
			while(!input.hasNextDouble()){
				System.out.println("对不起，不收假币！请重新付款");
				input.next();
			}
			double money=input.nextDouble();
			if(money>=sum){
				System.out.println("找钱"+(money-sum));
			}else{
				while(money<sum){
					System.out.println("付的钱不够！请重新付款");
					double smoney=input.nextDouble();
					money=smoney;
				}
				System.out.println("找钱"+(money-sum));
			}
		}
	}
